//
//  WDMineViewModel.m
//  wd-userapp
//
//  Created by Bin Tang on 2022/12/27.
//

#import "WDMineViewModel.h"

@implementation WDMineViewModel

- (void)initialize
{
    [super initialize];
    
    self.title = @"我的";
    
    TYZCommonCellModel *model = [TYZCommonCellModel new];
    model.title = @"修改密码";
    model.iconImgName = @"ic-mine-modify-pwd";
    [self.dataList addObject:model];
    
    model = [TYZCommonCellModel new];
    model.title = @"关于我们";
    model.iconImgName = @"ic-mine-about";
    [self.dataList addObject:model];
    
    
}


/// 退出登录
/// - Parameter completion: completion description
- (void)requestWithLogout:(RequestCompletionBlock)completion {
    @weakify(self);
    WDAppLogoutRequest *request = [[WDAppLogoutRequest alloc] init];
    [request startWithCompletionBlockWithSuccess:^(__kindof TYZBaseRequest * _Nonnull request) {
        @strongify(self);
        EDSRespondDataEntity *respond = request.responseModelObject;
        if (respond.code == EDS_NETWORK_SUCCESS) {
            ZHCustomUserInfoModel *userInfo = [[EDSAppDelegateTool sharedInstance] getUserInfo];
            userInfo.loginState = 0;
            userInfo.appToken = @"";
            [[EDSAppDelegateTool sharedInstance] saveUserInfo:userInfo];
        }
        [self sendResponseObject:request.responseModelObject completion:completion];
    } failure:^(__kindof TYZBaseRequest * _Nonnull request) {
        @strongify(self);
        [self sendResponseObject:request.responseModelObject completion:completion];
    }];
}

@end
